package com.spzx.order.service.impl;

import java.util.List;
import java.util.Arrays;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.spzx.common.core.utils.DateUtils;
import com.spzx.order.domain.OrderInfo;
import jakarta.annotation.Resource;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import com.spzx.order.mapper.OrderLogMapper;
import com.spzx.order.domain.OrderLog;
import com.spzx.order.service.IOrderLogService;

/**
 * 订单操作日志记录Service业务层处理
 *
 * @author atguigu
 * @date 2024-10-25
 */
@Service
public class OrderLogServiceImpl extends ServiceImpl<OrderLogMapper, OrderLog> implements IOrderLogService
{
    @Resource
    private OrderLogMapper orderLogMapper;

    /**
     * 查询订单操作日志记录列表
     *
     * @param orderLog 订单操作日志记录
     * @return 订单操作日志记录
     */
    @Override
    public List<OrderLog> selectOrderLogList(OrderLog orderLog)
    {
        return orderLogMapper.selectOrderLogList(orderLog);
    }
    /*
        异步保存日志
        @Async 是springcontext包提供的异步任务注解： 使用springtask默认的线程池
            - 一般开发时可以配置合适的异步线程池参数+优雅关闭异步任务线程池！

     */
    @Async
    @Override
    public void saveLogAsync(OrderInfo orderInfo) {
        OrderLog orderLog = new OrderLog();
        orderLog.setOrderId(orderInfo.getId());
        orderLog.setOperateUser("用户");
        orderLog.setProcessStatus(orderInfo.getOrderStatus());
        orderLog.setNote("提交订单");
        this.save(orderLog);
    }

}
